<?php
set_time_limit(0);
if (isset($_POST['op']) && isset($_POST['kong'])){
    include '../c/config.php';
     
    $openid=$_POST['op'];
    $phone=trim(addslashes($_POST['phone']));
    $leftTime=trim(addslashes($_POST['leftTime']));
    $nianji=trim(addslashes($_POST['nianji']));
     
    $mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
    if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqli->error);}

    if(6 == $nianji || 7 == $nianji){
        $table="t6";
    }else{
        $table="t9";
    }
      
    $mysqli->query("INSERT INTO `".$table."` (`id`, `uid`, `phone` ,`kong`,`createtime`,`lefttime`) VALUES (NULL,'".$openid."','".$phone."', '".json_encode($_POST['kong'], JSON_UNESCAPED_UNICODE)."', '".date("Y-m-d H:i:s")."','".$leftTime."')");
    $mysqli->close();
    echo json_encode(array('s'=>'y'));
     
}else{
    echo json_encode(array('s'=>'n'));
}

?>